package com.sunyard.dal.mapper;

import com.sunyard.dal.bo.role.RolePopedomBO;
import com.sunyard.dal.entity.OrgPopedom;
import com.sunyard.dal.entity.Popedom;
import com.sunyard.dal.entity.RolePopedom;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

public interface PopedomMapper {

    int deleteByPrimaryKey(String popedomId);

    int insert(Popedom record);

    int insertSelective(Popedom record);

    Popedom selectByPrimaryKey(String popedomId);

    int updateByPrimaryKeySelective(Popedom record);

    int updateByPrimaryKey(Popedom record);

    List<Popedom> findByUserId(String opId);

    List<Popedom> findPopedomchild(Popedom popedom);

    /*权限分配相关*/
    //根据所属机构获取机构权限
    List<Popedom> getOrgPopedomByOrgId(String orgId);

    List<Popedom> getOrgPopedomWithoutDefaultByOrgId(String orgId);


    List<Popedom> getRolePopedomByRoleId(String roleId);

    List<Popedom> getRolePopedomWithoutDefaultByRoleId(String roleId);


    List<Popedom> findPopedomTreeByOpId(String opId);

    int insertOrgPopedomTep(List<OrgPopedom> orgPopedomList);

    List<OrgPopedom> findTepOrgPopedomListByOrgId(@Param("orgId") String orgId, @Param("auditId") String auditId);

    List<RolePopedom> findTepRolePopedomListByRoleId(@Param("roleId") String roleId, @Param("auditId") String auditId);

    int deleteOrgPopedom(String orgId);

    int deleteOrgPopedomTep(String orgId);

    int insertOrgPopedom(List<OrgPopedom> orgPopedomList);

    int insertRolePopedomTep(@Param("list") List<RolePopedom> rolePopedomList);

    List<RolePopedom> findRolePopedomListByRoleId(String roleId);

    int deleteRolePopedom(String roleId);

    int insertRolePopedom(@Param("list") List<RolePopedom> rolePopedomList);

    int deleteRolePopedomTep(String roleId);

    List<Popedom> getPopedomByOrgId(@Param("roleId") String roleId);

    List<Popedom> getPopedomByRoleId(String roleId);

    List<Popedom> getPopedomByMchntRoleId(String mchntRoleId);

    List<String> findPopedomTreeByOrgId(@Param("orgId") String orgId);

    List<String> findPopedomTreeByRoleId(@Param("roleId") String roleId);

    //获取原有机构权限
    List<OrgPopedom> findOrgPopedomListByOrgId(String orgId);

    int deleteSubOrgPopedom(Map<String, Object> deleteMap);

    int findPopedomByUrl(@Param("url") String url);

    List<Popedom> getTempOrgPopedomByOrgId(String orgId);

    List<Popedom> getTempRolePopedomByOrgId(String roleId);

    List<Popedom> getOrgPopedomByIdAndSn(@Param("orgId") String orgId, @Param("oldAuditSn") int oldAuditSn);

    List<Popedom> getRolePopedomByIdAndSn(@Param("roleId") String roleId, @Param("oldAuditSn") int oldAuditSn);

    List<Popedom> getRolePopedomByUserType(@Param("userType") String userType);

    List<Integer> getOrgPopedomTmpByOrgId(String orgId);

    int maxRolePopedomAuditSn(String popedomId);

    List<Integer> getRolePopedomTmpByRoleId(String roleId);

    List<Popedom> getAllpopedom();

    List<Popedom> getAllPopedomByOrgId(@Param("orgId") String orgId);

    List<String> getPopedomIdByuri(@Param("uri") String uri);

    String getMchntPopedomIdByuri(@Param("uri") String uri);

    List<String> getAllpopedomLink();

    List<String> getAllmchntpopedomLink();

    /**
     * shiro获取当前用户所有权限
     */
    List<String> getShiroList(@Param("roleId") String roleId);

    List<String> getMchntShiroList(@Param("mchntRoleId") String mchntRoleId);

    List<String> findDefaultPopedomsByPid(@Param("list") List<String> popedomIds);

    List<String> getPopedomIdsList(String popedomId);

    /**
     * 获取菜单排序最大数
     *
     * @return int
     * @author: guangw.dang
     * @Date: 2022/6/7 20:07
     **/
    int getMaxSort();

    /**
     * 获取一级菜单最大编号
     *
     * @param popedomPid [popedomPid]
     * @return String
     **/
    int getMaxPopedomId(String popedomPid);

    /**
     * 角色权限分配
     *
     * @param rolePopedomList [rolePopedomList]
     * @return int
     **/
    int insertRolePopedomList(List<RolePopedomBO> rolePopedomList);

    /**
     * 通过popedomPid查询信息
     *
     * @param popedomPid [popedomPid]
     * @return PopedomDO
     * @author: guangw.dang
     * @Date: 2022/6/8 14:13
     **/
    Popedom selectByPopedomPid(String popedomPid);

    /**
     * 通过popedomName查询信息
     *
     * @param popedomName [popedomName]
     * @return Popedom
     **/
    Popedom selectByPopedomName(String popedomName);

    int getByRoleIdAndPodedomId(@Param("roleId") String roleId, @Param("popedomId") String popedomId);

    String getPopedomRelationByPopedomId(String popedomId);

    List<String> getRoleIdByPopedomId(String popedomId);

    List<String> getPopedomIdByRoleId(String roleId);


    int findPopedomByroleId(@Param("roleId") String roleId);
}
